﻿using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Web.Mvc;
using OurWedding.Controllers;
using OurWedding.Helpers;
using System.Collections.Generic;
using OurWedding.Models;
using Microsoft.QualityTools.Testing.Fakes;
using DataLayer.Entities.Fakes;
using DataLayer.Implementations.Fakes;

namespace OurWeddingTests
{
    [TestClass]
    public class InvitationTests
    {
        [TestMethod]
        public void InvitationControllerIndexShowsInvitationView()
        {
            using (ShimsContext.Create())
            {
                ShimInvitationApplication.AllInstances.GetByKeyString = (a, s) => new DataLayer.Entities.Invitation()
                {
                    Person = new DataLayer.Entities.Person() { Name = "" }
                };
                InvitationController controller = new InvitationController();
                ViewResult view = (ViewResult)controller.Index("2");

                Assert.AreEqual("Invitation", view.ViewName, "Retrieved view is not the right one");
            }
        }

        [TestMethod]
        public void GetInvitationModelFromDatabase()
        {
            using (ShimsContext.Create())
            {
                string name = "myName";

                ShimInvitationApplication.AllInstances.GetByKeyString = (a, s) => new DataLayer.Entities.Invitation()
                {
                    Person = new DataLayer.Entities.Person() { Name  = name}
                };

                InvitationHelper helper = new InvitationHelper();

                Invitation actual = helper.GetInvitation("1");

                Assert.AreEqual(name, actual.Person.Name, false, "Person is not the same");
            }

        }
    }
}
